<template>
  <a-card hoverable class="agent-card" :bordered="false" @click="handleView">
    <template #cover>
      <div class="cover-image" :style="{ backgroundColor: agent.color }">
        <component :is="agent.icon" class="icon-svg" />
      </div>
    </template>

    <a-card-meta>
      <template #title>
        <h3 class="card-title">{{ agent.name }}</h3>
      </template>
      <template #description>
        <div class="description-wrapper">
          <p class="desc-text">{{ agent.description }}</p>
        </div>
      </template>
    </a-card-meta>
  </a-card>
</template>

<script setup>
import { defineEmits, defineProps } from 'vue'

const props = defineProps({
  agent: {
    type: Object,
    required: true
  }
})

const emit = defineEmits(['view'])
const handleView = () => emit('view', props.agent.path)
</script>

<style scoped>
.agent-card {
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  height: 100%;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  background: #ffffff;
}

.agent-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
  border-color: transparent;
}

.cover-image {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.icon-svg {
  font-size: 36px;
  color: #ffffff;
  transition: transform 0.3s;
}

.agent-card:hover .icon-svg {
  transform: scale(1.1);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #262626;
  margin: 0;
  line-height: 1.4;
}

.description-wrapper {
  margin-top: 8px;
  flex: 1;
}

.desc-text {
  margin: 0;
  font-size: 13px;
  color: #595959;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* 多一行，更友好 */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 小屏优化 */
@media (max-width: 576px) {
  .agent-card {
    border-radius: 12px;
  }
  .card-title {
    font-size: 15px;
  }
  .desc-text {
    font-size: 12px;
  }
}
</style>
